import request from "@/utils/request.ts";
import type {
    ResAllSaleAttr,
    ResData,
    ResSaleAttrType,
    ResSPUImgType,
    ResTradeMark,
    SpuData
} from "@/api/product/spu/type.ts";

export const reqSPU = (page:number,size:number,c3ID:number|null) => request.get<any,ResData>(`/admin/product/${page}/${size}?category3Id=${c3ID}`);
export const reqTradeMark = () => request.get<any,ResTradeMark>(`/admin/product/baseTrademark/getTrademarkList`);
export const reqImages = (spuId:number) => request.get<any,ResSPUImgType>(`/admin/product/spuImageList/${spuId}`);
export const reqSaleAttr = (spuId:number) => request.get<any,ResSaleAttrType>(`/admin/product/spuSaleAttrList/${spuId}`);
export const reqAllSaleAttr = () => request.get<any,ResAllSaleAttr>(`/admin/product/baseSaleAttrList`);
export const reqSaveOrUpdateSPU = (data:SpuData) => {
    if(data.id)
        return  request.post(`/admin/product/updateSpuInfo`,data);
    else
        return request.post(`/admin/product/saveSpuInfo`,data);
}
